package com.ssy.lingxi.pay.model.allInPayModel;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ssy.lingxi.pay.api.model.vo.request.allInPay.BatchPayVO;
import com.ssy.lingxi.pay.api.model.vo.request.allInPay.RecieverVO;
import com.ssy.lingxi.pay.api.model.vo.request.allInPay.RefundPayeeVO;
import com.ssy.lingxi.pay.utils.IDGenerator;
import com.ssy.lingxi.pay.utils.RSAUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

@Slf4j
public class OrderServiceUtil {
    /**
     * 充值申请接口范例
     */
    public static String depositApply(String bizUserId, String bizOrderNo, String payMethodStr, String bankCardNo,
                                      String limitPay, String wx_openid, String ali_user_id, String vspCusid, String subAppId, String subMchId,
                                      String payType, String accountSetNo, String frontUrl, String backUrl, Long amount, String cacheParams, String url, String cusIp) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "depositApply");
        if (bizUserId == null || bizUserId.equals(""))
            log.error("API_ERROR[depositApply RESULT=[bizUserId is null]");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();
        //设置默认值
        long validateType = 0L;
        // 支付方式
        // 网关
        if ("GATEWAY".equals(payMethodStr)) {
            // 网关
            // String frontUrl =
            // "http://122.227.225.142:23661/gateway/getPayFront.jsp";
            // String frontUrl = "http://10.55.3.236:6003/gateway/getPayFront.jsp";
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCode", "vbank"); // 虚拟银行，专门用于测试环境
            // gatewayPay.put("bankCode", "cmb"); //生产环境
            payMap.put("payType", 1L);
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams)); // 借记卡
            payMap.put("amount", amount);

            payMethod.put("GATEWAY", payMap);
        } else if ("POSPAY".equals(payMethodStr) || "POSPAY_SZ".equals(payMethodStr)) {
            // 订单POS
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("amount", amount);

            payMethod.put("POSPAY", payMap);
        } else if ("REALNAMEPAY".equals(payMethodStr)) {
            // 实名付（单笔）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMap.put("amount", amount); // 分
            payMethod.put("REALNAMEPAY", payMap);
        } else if ("REALNAMEPAY_BATCH".equals(payMethodStr)) {
            // 实名付（batch）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMap.put("amount", amount); // 分
            payMethod.put("REALNAMEPAY_BATCH", payMap);
        } else if ("WITHHOLD_TLT".equals(payMethodStr)) {
            // 通联通代扣
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMap.put("amount", amount); // 分
            payMethod.put("WITHHOLD_TLT", payMap);
        } else if ("QUICKPAY_TLT".equals(payMethodStr)) {
            // 通联通协议支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMap.put("amount", amount); // 分
            payMethod.put("QUICKPAY_TLT", payMap);
        } else if ("WECHATPAY_MiniProgram".equals(payMethodStr)) {
            // 微信小程序支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("acct", wx_openid);
            payMethod.put("WECHATPAY_MiniProgram", payMap);
        } else if ("WECHATPAY_MINIPROGRAM_ORG".equals(payMethodStr)) {
            // 微信小程序支付（集团）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusid);
            payMap.put("subAppid", subAppId);
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("acct", wx_openid);
            payMethod.put("WECHATPAY_MINIPROGRAM_ORG", payMap);
        } else if ("WECHATPAY_APP".equals(payMethodStr)) {
            // 微信APP支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("Acct", wx_openid);
            payMap.put("subAppId", subAppId);// 微信appid,平台有多个APP时需上送
            payMap.put("subMchId", subMchId);// 微信子商户号,平台有多个APP时需上送
            payMethod.put("WECHATPAY_APP", payMap);
        } else if ("WeChatPAY-APP_OPEN".equals(payMethodStr)) {
            // 微信原生APP支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("subAppId", subAppId);// 微信端应用ID：appid
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMethod.put("WeChatPAY-APP_OPEN", payMap);
        } else if ("SCAN_WEIXIN".equals(payMethodStr)) {
            // 微信扫码支付正扫
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("payType", "W02"); // 非贷记卡：W02, 借、贷卡：W01
            payMap.put("amount", amount); // 分
            payMap.put("limitPay", limitPay); // 分
            payMethod.put("SCAN_WEIXIN", payMap);
        } else if ("SCAN_WEIXIN_ORG".equals(payMethodStr)) {
            // 微信扫码支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusid);
            payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_WEIXIN_ORG", payMap);
        } else if ("WECHAT_PUBLIC".equals(payMethodStr)) {
            // 微信JS支付（公众号）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("payType", limitPay); // 非贷记卡：no_credit 借、贷记卡：””
            payMap.put("acct", wx_openid); // 微信JS支付openid——微信分配
            payMap.put("amount", amount); // 分
            payMethod.put("WECHAT_PUBLIC", payMap);
        } else if ("SCAN_ALIPAY".equals(payMethodStr)) {
            // 支付宝支付正扫
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("payType", "A01"); // 传值：A01
            payMap.put("amount", amount); // 分
            payMap.put("limitPay", limitPay);
            payMethod.put("SCAN_ALIPAY", payMap);
        } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
            // 支付宝支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusid);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_ALIPAY_ORG", payMap);
        } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
            // 支付宝JS支付（生活号）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("acct", ali_user_id);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_ALIPAY_ORG", payMap);
        } else if ("QQ_WALLET".equals(payMethodStr)) {
            // QQ钱包JS支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("QQ_WALLET", payMap);
        } else if ("BALANCE".equals(payMethodStr)) {
            // 账户余额
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("accountSetNo", accountSetNo);
            payMap.put("amount", amount); // 分
            payMethod.put("BALANCE", payMap);
            validateType = 1L;//需要短信验证
        } /*else if ("WECHATPAY_H5".equals(payMethodStr)) {
            // 账户余额
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("limitPay", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("apptype", "IOS");// 枚举值：IOS，Android，Wap
            payMap.put("appname", "喜马拉雅");// 商户app名称；app名称或者网站名称,例如 王者荣耀
            payMap.put("apppackage", "com.tencent.mobileqq");
            payMap.put("cusip", "192.168.14.100");
            payMethod.put("WECHATPAY_H5", payMap);
        }*/ else if ("WECHAT_PUBLIC_ORG".equals(payMethodStr)) {
            // 微信JS支付（公众号）_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与公众号对应
            payMap.put("amount", amount); // 分
            payMap.put("limitPay", limitPay);
            payMap.put("acct", wx_openid);
            payMap.put("payType", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("WECHAT_PUBLIC_ORG", payMap);
        } else if ("ALIPAY_SERVICE_ORG".equals(payMethodStr)) {
            // 支付宝JS支付_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与生活号对应
            payMap.put("amount", amount); // 分
            payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("ALIPAY_SERVICE_ORG", payMap);
        } else if ("QQ_WALLET_ORG".equals(payMethodStr)) {
            // QQ钱包JS支付_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号
            payMap.put("amount", amount); // 分
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("QQ_WALLET_ORG", payMap);
        } else if ("ORDER_VSPPAY".equals(payMethodStr)) {
            // 收银宝POS当面付及订单模式支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            payMap.put("amount", amount); // 分
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("ORDER_VSPPAY", payMap);
        } else if ("QUICKPAY_H5".equals(payMethodStr) || "QUICKPAY_PC".equals(payMethodStr)) {
            // 新移动H5/PC快捷支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            payMap.put("amount", amount); // 分
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("QUICKPAY_H5", payMap);
        } else if ("WECHATPAY_APP_ORG".equals(payMethodStr)) {
            // 微信APP支付_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号
            payMap.put("limitPay", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("subAppId", subAppId);
            payMap.put("subMchId", subMchId);
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("WECHATPAY_APP_ORG", payMap);
        } else if ("ALIPAY_APP_OPEN".equals(payMethodStr)) {
            // 支付宝原生APP支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            // payMap.put("enablePayChannels", subAppId);
            // payMap.put("paysummary", subMchId);
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("ALIPAY_APP_OPEN", payMap);
        } else if ("VIRTUAL_IN".equals(payMethodStr)) {
            // 通用虚拟入金
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("extChannelNo", "AUTO");
            payMap.put("extAccount", "AUTO");
            payMap.put("paysummary", "AUTO");
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("VIRTUAL_IN", payMap);
        } else if ("WITHHOLD_SD".equals(payMethodStr)) {
            // 山东代收
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMap.put("PROVINCE", "上海");
            payMap.put("CITY", "浦东新区");
            payMap.put("amount", amount); // 分
            // payMap.put("extChannelNo", "AUTO");
            // payMap.put("extAccount", "AUTO");
            payMap.put("paysummary", "AUTO");
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("WITHHOLD_SD", payMap);
        } else if ("GATEWAY_VSP".equals(payMethodStr)) {
            // 收银宝网关支付
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("paytype", "B2C,B2B");
            payMethod.put("GATEWAY_VSP", payMap);
        } else if ("QUICKPAY_VSP".equals(payMethodStr)) {
            // 收银宝快捷支付
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMethod.put("QUICKPAY_VSP", payMap);
            validateType = 1L;//需要短信验证
        } else if ("WECHATPAY_H5_OPEN".equals(payMethodStr)) {
            //微信原生H5支付
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("subAppId", subAppId); // 微信端应用ID:appid
            payMap.put("cusip", cusIp); // 用户下单及调起支付的终端IP
            payMap.put("sceneInfo", "{\"h5_info\": {\"type\":\"IOS\",\"app_name\": \"王者 荣耀\",\"bundle_id\": \"com.tencent.wzryIOS\"}}");
            payMap.put("limitPay", limitPay);
            payMethod.put("WECHATPAY_H5_OPEN", payMap);
        }
        request.put("bizUserId", bizUserId);
        request.put("bizOrderNo", bizOrderNo);
        request.put("accountSetNo", accountSetNo);
        request.put("amount", amount);
        request.put("fee", 0L);
        request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码
        request.put("frontUrl", frontUrl);// 前台通知地址
        request.put("backUrl", backUrl);// 后台通知地址
        request.put("ordErexpireDatetime", ordErexpireDatetime);
        request.put("payMethod", JSONObject.toJSON(payMethod));
        request.put("goodsName", "computer");
        request.put("industryCode", "1910");
        request.put("industryName", "其他");
        request.put("source", 2L);
        request.put("summary", "AUTO-TEST depositApply");
        request.put("extendInfo", "AUTO-TEST this is extendInfo");
        return YunClient.request(request, cacheParams, url);

    }

    /**
     * 提现申请接口
     *
     * @param bizUserId    商户系统用户标识，商户系 统中唯一编号。
     * @param bizOrderNo   商户订单号（支付订单）
     * @param accountSetNo 账户集编号 个人会员、企业会员填写托管专用 账户集编号 若平台，填写平台对应账户集编号， 详细注：不支持 100002-标准保护金账户 集，100003-准备金额度账户集、 100004/5 中间账户集
     * @param amount       订单金额
     * @param payMethodStr 支付方式
     * @param bankCardNo   银行卡号/账号
     * @param bankCardPro  银行卡/账户属性 0：个人银行卡 1：企业对公账户 如果不传默认为 0 平台提现，必填 1
     * @param unionBank    支付行号
     * @param bankName     银行名称
     * @param province     省
     * @param city         城市
     * @param withdrawType 提现方式
     * @param backUrl      后台回调地址
     * @return 操作结果
     */
    public static String withdrawApply(String bizUserId, String bizOrderNo, String accountSetNo, Long amount,
                                       String payMethodStr, String bankCardNo, Long bankCardPro, String unionBank, String bankName,
                                       String province, String city, String withdrawType, String backUrl, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "withdrawApply");
        if (bizUserId == null || bizUserId.equals(""))
            log.error("API_ERROR[withdrawApply RESULT=[bizUserId is null]");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        request.put("bizUserId", bizUserId);
        request.put("bizOrderNo", bizOrderNo);
        request.put("accountSetNo", accountSetNo);
        request.put("amount", amount);
        request.put("fee", 0L);
        request.put("validateType", 0L); // 0: 无验证；1：短信；2：支付密码
        // request.put("frontUrl", frontUrl);//前台通知地址
        request.put("backUrl", backUrl);// 后台通知地址
        request.put("ordErexpireDatetime", ordErexpireDatetime);
        // request.put("payMethod", JSONObject.toJSON(payMethod));
        request.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
        request.put("bankCardPro", bankCardPro);
        request.put("withdrawType", withdrawType);
        request.put("industryCode", "1910");
        request.put("industryName", "其他");

        request.put("source", 2L);
        request.put("summary", "AUTO-TEST withdrawApply");
        request.put("extendInfo", "AUTO-TEST this is extendInfo");

        return YunClient.request(request, cacheParams, url);

    }


    /**
     * 消费申请（不是所有字段都要用上）
     *
     * @param payerId      商户系统用户标识，商户 系统中唯一编号。 付款方
     * @param recieverId   商户系统用户标识，商户 系统中唯一编号。 收款方
     * @param amount       商户订单号（支付订单）
     * @param validateType 订单金额
     * @param frontUrl     前台通知地址
     * @param backUrl      后台通知地址
     * @param payMethodStr 支付方式
     * @param bankCardNo   银行卡号/账号
     * @param limitPay     非贷记卡：no_credit 借、贷记卡：””需要传空字符串， 不能不传
     */
/*
    public static String consumeApply(String payerId, String recieverId, String bizOrderNo, Long amount,
                                      Long validateType, String frontUrl, String backUrl, String payMethodStr, String bankCardNo,
                                      String limitPay, String wx_openid, String ali_user_id, String vspCusid, String subAppId, String subMchId,
                                      String authcode, Long bankCardPro, String unionBank, String bankName, String accountSetNo,
                                      String province, String city, String withdrawType, String extendInfo) throws Exception {

        final YunRequest request = new YunRequest("OrderService", "consumeApply");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();
        // 支付方式
        // 网关
        if ("GATEWAY".equals(payMethodStr)) {
            // 网关
            // String frontUrl =
            // "http://122.227.225.142:23661/gateway/getPayFront.jsp";
            // String frontUrl = "http://10.55.3.236:6003/gateway/getPayFront.jsp";
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCode", "vbank"); // 虚拟银行，专门用于测试环境
            // gatewayPay.put("bankCode", "cmb"); //生产环境
            payMap.put("payType", 1L);
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo)); // 借记卡
            payMap.put("amount", amount);

            payMethod.put("GATEWAY", payMap);
        } else if ("POSPAY".equals(payMethodStr) || "POSPAY_SZ".equals(payMethodStr)) {
            // 订单POS
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("amount", amount);

            payMethod.put("POSPAY", payMap);
        } else if ("REALNAMEPAY".equals(payMethodStr)) {
            // 实名付（单笔）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
            payMap.put("amount", amount); // 分
            payMethod.put("REALNAMEPAY", payMap);
        } else if ("REALNAMEPAY_BATCH".equals(payMethodStr)) {
            // 实名付（batch）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
            payMap.put("amount", amount); // 分
            payMethod.put("REALNAMEPAY_BATCH", payMap);
        } else if ("WITHHOLD_TLT".equals(payMethodStr)) {
            // 通联通代扣
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
            payMap.put("amount", amount); // 分
            payMethod.put("WITHHOLD_TLT", payMap);
        } else if ("QUICKPAY_TLT".equals(payMethodStr)) {
            // 通联通协议支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
            payMap.put("amount", amount); // 分
            payMethod.put("QUICKPAY_TLT", payMap);
        } else if ("WECHATPAY_MiniProgram".equals(payMethodStr)) {
            // 微信小程序支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("Acct", wx_openid);
            payMethod.put("WECHATPAY_MiniProgram", payMap);
        } else if ("WECHATPAY_MINIPROGRAM_ORG".equals(payMethodStr)) {
            // 微信小程序支付（集团）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusid);
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("acct", wx_openid);
            payMethod.put("WECHATPAY_MINIPROGRAM_ORG", payMap);
        } else if ("WECHATPAY_APP".equals(payMethodStr)) {
            // 微信APP支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("Acct", wx_openid);
            payMap.put("subAppId", subAppId);// 微信appid,平台有多个APP时需上送
            payMap.put("subMchId", subMchId);// 微信子商户号,平台有多个APP时需上送
            payMethod.put("WECHATPAY_APP", payMap);
        } else if ("WeChatPAY-APP_OPEN".equals(payMethodStr)) {
            // 微信原生APP支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("subAppId", subAppId);// 微信端应用ID：appid
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMethod.put("WeChatPAY-APP_OPEN", payMap);
        } else if ("SCAN_WEIXIN".equals(payMethodStr)) {
            // 微信扫码支付正扫（目前需要对接）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("payType", "W02"); // 非贷记卡：W02, 借、贷卡：W01
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_WEIXIN", payMap);
        } else if ("SCAN_WEIXIN_ORG".equals(payMethodStr)) {
            // 微信扫码支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusid);
            payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_WEIXIN_ORG", payMap);
        } else if ("WECHAT_PUBLIC".equals(payMethodStr)) {
            // 微信JS支付（公众号）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("payType", limitPay); // 非贷记卡：no_credit 借、贷记卡：””
            payMap.put("acct", wx_openid); // 微信JS支付openid——微信分配
            payMap.put("amount", amount); // 分
            payMethod.put("WECHAT_PUBLIC", payMap);
        } else if ("SCAN_ALIPAY".equals(payMethodStr)) {
            // 支付宝支付正扫（目前需要对接）
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("payType", "A01"); // 传值：A01
            payMap.put("amount", amount); // 分
            payMap.put("limitPay", "no_credit"); // 非贷记卡：no_credit 借、贷记卡：””，需要传空字符 串，不能不传
            payMethod.put("SCAN_ALIPAY", payMap);
        } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
            // 支付宝支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusid);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_ALIPAY_ORG", payMap);
        } else if ("ALIPAY_SERVICE".equals(payMethodStr)) {
            // 支付宝JS支付（生活号）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("acct", ali_user_id);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_ALIPAY_ORG", payMap);
        } else if ("QQ_WALLET".equals(payMethodStr)) {
            // QQ钱包JS支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("QQ_WALLET", payMap);
        } else if ("CODEPAY_W".equals(payMethodStr)) {
            // 微信刷卡支付（被扫）
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("authcode", authcode);
            payMethod.put("CODEPAY_W", payMap);
        } else if ("CODEPAY_A".equals(payMethodStr)) {
            // 支付宝刷卡支付(被扫)
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("authcode", authcode);
            payMethod.put("CODEPAY_A", payMap);
        } else if ("CODEPAY_Q".equals(payMethodStr)) {
            // QQ刷卡支付(被扫)
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("authcode", authcode);
            payMethod.put("CODEPAY_Q", payMap);
        } else if ("BALANCE".equals(payMethodStr)) {
            // 账户余额（需对接）
          */
/*      HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("accountSetNo", accountSetNo);
                payMap.put("amount", amount); // 分*//*

            JSONArray balancePay = new JSONArray();
            JSONObject balance = new JSONObject();
            balance.put("accountSetNo", accountSetNo);
            balance.put("amount", amount);
            balancePay.add(balance);
            payMethod.put("BALANCE", balancePay);
        } else if ("WECHATPAY_H5".equals(payMethodStr)) {
            // 账户余额
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("limitPay", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("apptype", "IOS");// 枚举值：IOS，Android，Wap
            payMap.put("appname", "喜马拉雅");// 商户app名称；app名称或者网站名称,例如 王者荣耀
            payMap.put("apppackage", "com.tencent.mobileqq");
            payMap.put("cusip", "192.168.14.100");
            payMethod.put("WECHATPAY_H5", payMap);
        } else if ("WECHAT_PUBLIC_ORG".equals(payMethodStr)) {
            // 微信JS支付（公众号）_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与公众号对应
            payMap.put("amount", amount); // 分
            payMap.put("acct", wx_openid);
            payMap.put("payType", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("WECHAT_PUBLIC_ORG", payMap);
        } else if ("ALIPAY_SERVICE_ORG".equals(payMethodStr)) {
            // 支付宝JS支付_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与生活号对应
            payMap.put("amount", amount); // 分
            payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("ALIPAY_SERVICE_ORG", payMap);
        } else if ("QQ_WALLET_ORG".equals(payMethodStr)) {
            // QQ钱包JS支付_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号
            payMap.put("amount", amount); // 分
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("QQ_WALLET_ORG", payMap);
        } else if ("ORDER_VSPPAY".equals(payMethodStr)) {
            // 收银宝POS当面付及订单模式支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            payMap.put("amount", amount); // 分
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("ORDER_VSPPAY", payMap);
        } else if ("QUICKPAY_H5".equals(payMethodStr) || "QUICKPAY_PC".equals(payMethodStr)) {
            // 新移动H5/PC快捷支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            payMap.put("amount", amount); // 分
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("QUICKPAY_H5", payMap);
        } else if ("WECHATPAY_APP_ORG".equals(payMethodStr)) {
            // 微信APP支付_集团
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("vspCusid", vspCusid); // 收银宝子商户号
            payMap.put("limitPay", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("subAppId", subAppId);
            payMap.put("subMchId", subMchId);
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("WECHATPAY_APP_ORG", payMap);
        } else if ("ALIPAY_APP_OPEN".equals(payMethodStr)) {
            // 支付宝原生APP支付
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            // payMap.put("enablePayChannels", subAppId);
            // payMap.put("paysummary", subMchId);
            // payMap.put("acct", ali_user_id);
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("ALIPAY_APP_OPEN", payMap);
        } else if ("VIRTUAL_IN".equals(payMethodStr)) {
            // 通用虚拟入金
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            // payMap.put("vspCusid", vspCusid); //收银宝子商户号
            // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMap.put("extChannelNo", "AUTO");
            payMap.put("extAccount", "AUTO");
            payMap.put("paysummary", "AUTO");
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("VIRTUAL_IN", payMap);
        } else if ("WITHHOLD_SD".equals(payMethodStr)) {
            // 山东代收
            HashMap<String, Object> payMap = new HashMap<>();
            // aliPay.put("acct", ali_user_id);
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
            payMap.put("PROVINCE", "上海");
            payMap.put("CITY", "浦东新区");
            payMap.put("amount", amount); // 分
            // payMap.put("extChannelNo", "AUTO");
            // payMap.put("extAccount", "AUTO");
            payMap.put("paysummary", "AUTO");
            // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
            payMethod.put("WITHHOLD_SD", payMap);
        }

        // 组装支付方式

        // payMethod.put("QUICKPAY", quickPay);

        // payMethod.put("GATEWAY", gatewayPay);
        // payMethod.put("WITHHOLD_UP", daikouPay);
        // payMethod.put("WITHHOLD_TLT", tltDaikouPay);

        request.put("payerId", payerId);
        request.put("recieverId", recieverId);
        request.put("bizOrderNo", bizOrderNo);
        request.put("amount", amount);
        request.put("extendInfo", extendInfo);
        //request.put("accountSetNo", accountSetNo);

        request.put("fee", 0L);
        request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码
        //	request.put("frontUrl", frontUrl);//前台通知地址
        request.put("backUrl", backUrl);// 后台通知地址
        request.put("ordErexpireDatetime", ordErexpireDatetime);
        request.put("payMethod", payMethod);

        //request.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
        //request.put("bankCardPro", bankCardPro);
        //request.put("withdrawType", withdrawType);
        request.put("goodsName", "computer");
        request.put("industryCode", "1910");
        request.put("industryName", "其他");
        request.put("source", 2L);
        request.put("summary", "AUTO-TEST consumeApply");
        request.put("extendInfo", "AUTO-TEST this is extendInfo");


        return YunClient.request(request);
    }
*/

    /**
     * 带有分账规则的消费申请
     */
/*    public static HashMap<String, String> consumeApplyWithSplitRules(String bizUserId, String payerId, String recieverId, Long amount,
                                                                     Long validateType, String frontUrl, String backUrl, String payMethodStr, String bankCardNo,
                                                                     String limitPay, String wx_openid, String ali_user_id, String vspCusid, String subAppId, String subMchId,
                                                                     String authcode, Long bankCardPro, String unionBank, String bankName, String accountSetNo,
                                                                     String province, String city, String withdrawType) {
        log.info("================OrderAPI: consumeApplyWithSplitRules begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<>();
        final YunRequest request = new YunRequest("OrderService", "consumeApply");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();
        String bizOrderNo = "XF" + System.currentTimeMillis();

        String payStatus = "";
        String payFailMessage = "";
        String orderNo = "";
        String payCode = "";
        String tradeNo = "";
        String payInfo = "";
        String extendInfo = "";

        String weixinstr = "";
        String appid = "";
        String packageStr = "";
        String prepayid = "";
        String partnerid = "";
        String noncestr = "";
        String timestamp = "";
        String sign = "";

        // 支付方式
        try {
            // 网关
            if ("GATEWAY".equals(payMethodStr)) {
                // 网关
                // String frontUrl =
                // "http://122.227.225.142:23661/gateway/getPayFront.jsp";
                // String frontUrl = "http://10.55.3.236:6003/gateway/getPayFront.jsp";
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCode", "vbank"); // 虚拟银行，专门用于测试环境
                // gatewayPay.put("bankCode", "cmb"); //生产环境
                payMap.put("payType", 1L);
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo)); // 借记卡
                payMap.put("amount", amount);

                payMethod.put("GATEWAY", payMap);
            } else if ("POSPAY".equals(payMethodStr) || "POSPAY_SZ".equals(payMethodStr)) {
                // 订单POS
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("amount", amount);

                payMethod.put("POSPAY", payMap);
            } else if ("REALNAMEPAY".equals(payMethodStr)) {
                // 实名付（单笔）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("REALNAMEPAY", payMap);
            } else if ("REALNAMEPAY_BATCH".equals(payMethodStr)) {
                // 实名付（batch）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("REALNAMEPAY_BATCH", payMap);
            } else if ("WITHHOLD_TLT".equals(payMethodStr)) {
                // 通联通代扣
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("WITHHOLD_TLT", payMap);
            } else if ("QUICKPAY_TLT".equals(payMethodStr)) {
                // 通联通协议支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("QUICKPAY_TLT", payMap);
            } else if ("WECHATPAY_MiniProgram".equals(payMethodStr)) {
                // 微信小程序支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMap.put("Acct", wx_openid);
                payMethod.put("WECHATPAY_MiniProgram", payMap);
            } else if ("WECHATPAY_MINIPROGRAM_ORG".equals(payMethodStr)) {
                // 微信小程序支付（集团）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("vspCusid", vspCusid);
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMap.put("Acct", wx_openid);
                payMethod.put("WECHATPAY_MINIPROGRAM_ORG", payMap);
            } else if ("WECHATPAY_APP".equals(payMethodStr)) {
                // 微信APP支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMap.put("Acct", wx_openid);
                payMap.put("subAppId", subAppId);// 微信appid,平台有多个APP时需上送
                payMap.put("subMchId", subMchId);// 微信子商户号,平台有多个APP时需上送
                payMethod.put("WECHATPAY_APP", payMap);
            } else if ("WeChatPAY-APP_OPEN".equals(payMethodStr)) {
                // 微信原生APP支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("subAppId", subAppId);// 微信端应用ID：appid
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMethod.put("WeChatPAY-APP_OPEN", payMap);
            } else if ("SCAN_WEIXIN".equals(payMethodStr)) {
                // 微信扫码支付正扫
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("payType", "W02"); // 非贷记卡：W02, 借、贷卡：W01
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_WEIXIN", payMap);
            } else if ("SCAN_WEIXIN_ORG".equals(payMethodStr)) {
                // 微信扫码支付正扫 集团
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("vspCusid", vspCusid);
                payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_WEIXIN_ORG", payMap);
            } else if ("WECHAT_PUBLIC".equals(payMethodStr)) {
                // 微信JS支付（公众号）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("payType", limitPay); // 非贷记卡：no_credit 借、贷记卡：””
                payMap.put("acct", wx_openid); // 微信JS支付openid——微信分配
                payMap.put("amount", amount); // 分
                payMethod.put("WECHAT_PUBLIC", payMap);
            } else if ("SCAN_ALIPAY".equals(payMethodStr)) {
                // 支付宝支付正扫（需对接）
                HashMap<String, Object> payMap = new HashMap<>();
                // wechatMiniPay.put("vspCusid", vspCusid);
                payMap.put("payType", "A01"); // 传值：A01
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_ALIPAY", payMap);
            } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
                // 支付宝支付正扫 集团
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("vspCusid", vspCusid);
                // aliPay.put("payType", "A01"); //传值：A01
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_ALIPAY_ORG", payMap);
            } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
                // 支付宝JS支付（生活号）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("acct", ali_user_id);
                // aliPay.put("payType", "A01"); //传值：A01
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_ALIPAY_ORG", payMap);
            } else if ("QQ_WALLET".equals(payMethodStr)) {
                // QQ钱包JS支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // aliPay.put("payType", "A01"); //传值：A01
                payMap.put("amount", amount); // 分
                payMethod.put("QQ_WALLET", payMap);
            } else if ("CODEPAY_W".equals(payMethodStr)) {
                // 微信刷卡支付（被扫）
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("authcode", authcode);
                payMethod.put("CODEPAY_W", payMap);
            } else if ("CODEPAY_A".equals(payMethodStr)) {
                // 支付宝刷卡支付(被扫)
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("authcode", authcode);
                payMethod.put("CODEPAY_A", payMap);
            } else if ("CODEPAY_Q".equals(payMethodStr)) {
                // QQ刷卡支付(被扫)
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("authcode", authcode);
                payMethod.put("CODEPAY_Q", payMap);
            } else if ("BALANCE".equals(payMethodStr)) {
                // 账户余额（需对接）
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("accountSetNo", accountSetNo);
                payMap.put("amount", amount); // 分
                payMethod.put("BALANCE", payMap);
            } else if ("WECHATPAY_H5".equals(payMethodStr)) {
                // 账户余额
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("limitPay", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("apptype", "IOS");// 枚举值：IOS，Android，Wap
                payMap.put("appname", "喜马拉雅");// 商户app名称；app名称或者网站名称,例如 王者荣耀
                payMap.put("apppackage", "com.tencent.mobileqq");
                payMap.put("cusip", "192.168.14.100");
                payMethod.put("WECHATPAY_H5", payMap);
            } else if ("WECHAT_PUBLIC_ORG".equals(payMethodStr)) {
                // 微信JS支付（公众号）_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与公众号对应
                payMap.put("amount", amount); // 分
                payMap.put("acct", wx_openid);
                payMap.put("payType", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("WECHAT_PUBLIC_ORG", payMap);
            } else if ("ALIPAY_SERVICE_ORG".equals(payMethodStr)) {
                // 支付宝JS支付_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与生活号对应
                payMap.put("amount", amount); // 分
                payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("ALIPAY_SERVICE_ORG", payMap);
            } else if ("QQ_WALLET_ORG".equals(payMethodStr)) {
                // QQ钱包JS支付_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号
                payMap.put("amount", amount); // 分
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("QQ_WALLET_ORG", payMap);
            } else if ("ORDER_VSPPAY".equals(payMethodStr)) {
                // 收银宝POS当面付及订单模式支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                payMap.put("amount", amount); // 分
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("ORDER_VSPPAY", payMap);
            } else if ("QUICKPAY_H5".equals(payMethodStr) || "QUICKPAY_PC".equals(payMethodStr)) {
                // 新移动H5/PC快捷支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                payMap.put("amount", amount); // 分
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("QUICKPAY_H5", payMap);
            } else if ("WECHATPAY_APP_ORG".equals(payMethodStr)) {
                // 微信APP支付_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号
                payMap.put("limitPay", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("subAppId", subAppId);
                payMap.put("subMchId", subMchId);
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("WECHATPAY_APP_ORG", payMap);
            } else if ("ALIPAY_APP_OPEN".equals(payMethodStr)) {
                // 支付宝原生APP支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                // payMap.put("enablePayChannels", subAppId);
                // payMap.put("paysummary", subMchId);
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("ALIPAY_APP_OPEN", payMap);
            } else if ("VIRTUAL_IN".equals(payMethodStr)) {
                // 通用虚拟入金
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("extChannelNo", "AUTO");
                payMap.put("extAccount", "AUTO");
                payMap.put("paysummary", "AUTO");
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("VIRTUAL_IN", payMap);
            } else if ("WITHHOLD_SD".equals(payMethodStr)) {
                // 山东代收
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("PROVINCE", "上海");
                payMap.put("CITY", "浦东新区");
                payMap.put("amount", amount); // 分
                // payMap.put("extChannelNo", "AUTO");
                // payMap.put("extAccount", "AUTO");
                payMap.put("paysummary", "AUTO");
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("WITHHOLD_SD", payMap);
            }

            // 组装支付方式

            // payMethod.put("QUICKPAY", quickPay);

            // payMethod.put("GATEWAY", gatewayPay);
            // payMethod.put("WITHHOLD_UP", daikouPay);
            // payMethod.put("WITHHOLD_TLT", tltDaikouPay);

            request.put("payerId", payerId);
            request.put("recieverId", recieverId);
            request.put("bizOrderNo", bizOrderNo);
            request.put("amount", amount);
            //request.put("accountSetNo", accountSetNo);

            request.put("fee", 0L);
            request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码
            request.put("frontUrl", frontUrl);//前台通知地址
            request.put("backUrl", backUrl);// 后台通知地址

            //设置分账规则，固定：
            ArrayList splitRuleList = new ArrayList();

            HashMap<String, Object> splitRules1 = new HashMap<String, Object>();
            splitRules1.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules1.put("accountSetNo", accountSetNo);
            splitRules1.put("amount", 5L);
            splitRules1.put("fee", 0L);
            splitRules1.put("remark", "SplitRule AUTO-TEST");
            splitRuleList.add(splitRules1);

            HashMap<String, Object> splitRules2 = new HashMap<String, Object>();
            splitRules2.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules2.put("accountSetNo", accountSetNo);
            splitRules2.put("amount", 2L);
            splitRules2.put("fee", 0L);
            splitRules2.put("remark", "SplitRule AUTO-TEST2");
            splitRuleList.add(splitRules2);

            //splitRules.put("splitRule", splitRuleList);
            //request.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
            //request.put("bankCardPro", bankCardPro);
            //request.put("withdrawType", withdrawType);
            request.put("splitRule", splitRuleList);
            request.put("ordErexpireDatetime", ordErexpireDatetime);
            request.put("payMethod", JSONObject.toJSON(payMethod));

            request.put("goodsName", "computer");
            request.put("industryCode", "1910");
            request.put("industryName", "其他");
            request.put("source", 2L);
            request.put("summary", "AUTO-TEST consumeApply");
            request.put("extendInfo", "AUTO-TEST this is extendInfo");


            String res = YunClient.request(request);
            // System.out.println("res: " + res);
            JSONObject resp = JSON.parseObject(res);
            // System.out.println("status=[" + resp.getString("status") + "]");
            // System.out.println("signedValue=[" + resp.getString("signedValue") + "]");
            // System.out.println("sign=[" + resp.getString("sign") + "]");
            // System.out.println("errorCode=[" + resp.getString("errorCode") + "]");
            // System.out.println("message=[" + resp.getString("message") + "]");
            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                payStatus = resp.getJSONObject("signedValue").getString("payStatus");
                payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");
                orderNo = resp.getJSONObject("signedValue").getString("orderNo");
                tradeNo = resp.getJSONObject("signedValue").getString("tradeNo");
                payCode = resp.getJSONObject("signedValue").getString("payCode");
                extendInfo = resp.getJSONObject("signedValue").getString("extendInfo");
                payInfo = resp.getJSONObject("signedValue").getString("payInfo");
                if (payMethodStr.equals("WECHATPAY_APP")) {
                    appid = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("appid");
                    packageStr = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("package");
                    prepayid = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("prepayid");
                    partnerid = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("partnerid");
                    noncestr = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("noncestr");
                    timestamp = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("timestamp");
                    sign = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("sign");
                }
                log.info("API[consumeApplyWithSplitRules SUCCESS!]");
            } else {
                log.error("API_ERROR[consumeApplyWithSplitRules RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("payerId", payerId);
        result.put("recieverId", recieverId);
        result.put("bizOrderNo", bizOrderNo);
        result.put("orderNo", orderNo);
        result.put("tradeNo", tradeNo);
        result.put("payCode", payCode);
        result.put("extendInfo", extendInfo);
        result.put("payInfo", payInfo);
        result.put("payStatus", payStatus);
        result.put("payFailMessage", payFailMessage);
        //wechat pay must info
        result.put("appid", appid);
        result.put("packageStr", packageStr);
        result.put("prepayid", prepayid);
        result.put("partnerid", partnerid);
        result.put("noncestr", noncestr);
        result.put("timestamp", timestamp);
        result.put("sign", sign);

        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: consumeApplyWithSplitRules end================[elapse: " + elapse + " ms]");
        return result;
    }*/

    /**
     * 托管代收接口
     *
     * @param bizOrderNo
     * @param payerId
     * @param recieverId
     * @param amount
     * @param validateType
     * @param frontUrl
     * @param backUrl
     * @param payMethodStr
     * @param bankCardNo
     * @param limitPay
     * @param wx_openid
     * @param ali_user_id
     * @param vspCusid
     * @param subAppId
     * @param subMchId
     * @param authcode
     * @param bankCardPro
     * @param unionBank
     * @param bankName
     * @param accountSetNo
     * @param province
     * @param city
     * @param withdrawType
     * @return
     */
/*
    public static HashMap<String, String> agentCollectApply(String bizOrderNo, String payerId, String recieverId, Long amount,
                                                            Long validateType, String frontUrl, String backUrl, String payMethodStr, String bankCardNo,
                                                            String limitPay, String wx_openid, String ali_user_id, String vspCusid, String subAppId, String subMchId,
                                                            String authcode, Long bankCardPro, String unionBank, String bankName, String accountSetNo,
                                                            String province, String city, String withdrawType, JSONArray recieverList) {
        log.info("================OrderAPI: agentCollectApplySimplify begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "agentCollectApply");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();
        //  String bizOrderNo = "TGDSS" + System.currentTimeMillis();

        String payStatus = "";
        String payFailMessage = "";
        String orderNo = "";
        String payCode = "";
        String tradeNo = "";
        String payInfo = "";
        String extendInfo = "";

        String weixinstr = "";
        String appid = "";
        String packageStr = "";
        String prepayid = "";
        String partnerid = "";
        String noncestr = "";
        String timestamp = "";
        String sign = "";

        // 支付方式
        try {
            // 网关
            if ("GATEWAY".equals(payMethodStr)) {
                // 网关
                // String frontUrl =
                // "http://122.227.225.142:23661/gateway/getPayFront.jsp";
                // String frontUrl = "http://10.55.3.236:6003/gateway/getPayFront.jsp";
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCode", "vbank"); // 虚拟银行，专门用于测试环境
                // gatewayPay.put("bankCode", "cmb"); //生产环境
                payMap.put("payType", 1L);
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo)); // 借记卡
                payMap.put("amount", amount);

                payMethod.put("GATEWAY", payMap);
            } else if ("POSPAY".equals(payMethodStr) || "POSPAY_SZ".equals(payMethodStr)) {
                // 订单POS
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("amount", amount);

                payMethod.put("POSPAY", payMap);
            } else if ("REALNAMEPAY".equals(payMethodStr)) {
                // 实名付（单笔）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("REALNAMEPAY", payMap);
            } else if ("REALNAMEPAY_BATCH".equals(payMethodStr)) {
                // 实名付（batch）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("REALNAMEPAY_BATCH", payMap);
            } else if ("WITHHOLD_TLT".equals(payMethodStr)) {
                // 通联通代扣
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("WITHHOLD_TLT", payMap);
            } else if ("QUICKPAY_TLT".equals(payMethodStr)) {
                // 通联通协议支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("amount", amount); // 分
                payMethod.put("QUICKPAY_TLT", payMap);
            } else if ("WECHATPAY_MiniProgram".equals(payMethodStr)) {
                // 微信小程序支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMap.put("Acct", wx_openid);
                payMethod.put("WECHATPAY_MiniProgram", payMap);
            } else if ("WECHATPAY_MINIPROGRAM_ORG".equals(payMethodStr)) {
                // 微信小程序支付（集团）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("vspCusid", vspCusid);
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMap.put("Acct", wx_openid);
                payMethod.put("WECHATPAY_MINIPROGRAM_ORG", payMap);
            } else if ("WECHATPAY_APP".equals(payMethodStr)) {
                // 微信APP支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMap.put("Acct", wx_openid);
                payMap.put("subAppId", subAppId);// 微信appid,平台有多个APP时需上送
                payMap.put("subMchId", subMchId);// 微信子商户号,平台有多个APP时需上送
                payMethod.put("WECHATPAY_APP", payMap);
            } else if ("WeChatPAY-APP_OPEN".equals(payMethodStr)) {
                // 微信原生APP支付
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("subAppId", subAppId);// 微信端应用ID：appid
                payMap.put("limitPay", limitPay);
                payMap.put("amount", amount); // 分
                payMethod.put("WeChatPAY-APP_OPEN", payMap);
            } else if ("SCAN_WEIXIN".equals(payMethodStr)) {
                // 微信扫码支付正扫
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("payType", "W02"); // 非贷记卡：W02, 借、贷卡：W01
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_WEIXIN", payMap);
            } else if ("SCAN_WEIXIN_ORG".equals(payMethodStr)) {
                // 微信扫码支付正扫 集团
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("vspCusid", vspCusid);
                payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_WEIXIN_ORG", payMap);
            } else if ("WECHAT_PUBLIC".equals(payMethodStr)) {
                // 微信JS支付（公众号）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("payType", limitPay); // 非贷记卡：no_credit 借、贷记卡：””
                payMap.put("acct", wx_openid); // 微信JS支付openid——微信分配
                payMap.put("amount", amount); // 分
                payMethod.put("WECHAT_PUBLIC", payMap);
            } else if ("SCAN_ALIPAY".equals(payMethodStr)) {
                // 支付宝支付正扫
                HashMap<String, Object> payMap = new HashMap<>();
                // wechatMiniPay.put("vspCusid", vspCusid);
                payMap.put("payType", "A01"); // 传值：A01
                payMap.put("amount", amount); // 分
                payMap.put("limitPay", "no_credit"); // 分
                payMethod.put("SCAN_ALIPAY", payMap);
            } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
                // 支付宝支付正扫 集团
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("vspCusid", vspCusid);
                // aliPay.put("payType", "A01"); //传值：A01
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_ALIPAY_ORG", payMap);
            } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
                // 支付宝JS支付（生活号）
                HashMap<String, Object> payMap = new HashMap<>();
                payMap.put("acct", ali_user_id);
                // aliPay.put("payType", "A01"); //传值：A01
                payMap.put("amount", amount); // 分
                payMethod.put("SCAN_ALIPAY_ORG", payMap);
            } else if ("QQ_WALLET".equals(payMethodStr)) {
                // QQ钱包JS支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // aliPay.put("payType", "A01"); //传值：A01
                payMap.put("amount", amount); // 分
                payMethod.put("QQ_WALLET", payMap);
            } else if ("CODEPAY_W".equals(payMethodStr)) {
                // 微信刷卡支付（被扫）
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("authcode", authcode);
                payMethod.put("CODEPAY_W", payMap);
            } else if ("CODEPAY_A".equals(payMethodStr)) {
                // 支付宝刷卡支付(被扫)
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("authcode", authcode);
                payMethod.put("CODEPAY_A", payMap);
            } else if ("CODEPAY_Q".equals(payMethodStr)) {
                // QQ刷卡支付(被扫)
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("authcode", authcode);
                payMethod.put("CODEPAY_Q", payMap);
            } else if ("BALANCE".equals(payMethodStr)) {
                // 账户余额（需对接）
                JSONArray balancePay = new JSONArray();
                JSONObject balance = new JSONObject();
                balance.put("accountSetNo", accountSetNo);
                balance.put("amount", amount);
                balancePay.add(balance);
                payMethod.put("BALANCE", balancePay);
            } */
/*else if ("WECHATPAY_H5".equals(payMethodStr)) {
                // 账户余额
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("limitPay", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("apptype", "IOS");// 枚举值：IOS，Android，Wap
                payMap.put("appname", "喜马拉雅");// 商户app名称；app名称或者网站名称,例如 王者荣耀
                payMap.put("apppackage", "com.tencent.mobileqq");
                payMap.put("cusip", "192.168.14.100");
                payMethod.put("WECHATPAY_H5", payMap);
            } *//*
else if ("WECHAT_PUBLIC_ORG".equals(payMethodStr)) {
                // 微信JS支付（公众号）_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与公众号对应
                payMap.put("amount", amount); // 分
                payMap.put("acct", wx_openid);
                payMap.put("payType", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("WECHAT_PUBLIC_ORG", payMap);
            } else if ("ALIPAY_SERVICE_ORG".equals(payMethodStr)) {
                // 支付宝JS支付_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号，与生活号对应
                payMap.put("amount", amount); // 分
                payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("ALIPAY_SERVICE_ORG", payMap);
            } else if ("QQ_WALLET_ORG".equals(payMethodStr)) {
                // QQ钱包JS支付_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号
                payMap.put("amount", amount); // 分
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("QQ_WALLET_ORG", payMap);
            } else if ("ORDER_VSPPAY".equals(payMethodStr)) {
                // 收银宝POS当面付及订单模式支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                payMap.put("amount", amount); // 分
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("ORDER_VSPPAY", payMap);
            } else if ("QUICKPAY_H5".equals(payMethodStr) || "QUICKPAY_PC".equals(payMethodStr)) {
                // 新移动H5/PC快捷支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                payMap.put("amount", amount); // 分
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("QUICKPAY_H5", payMap);
            } else if ("WECHATPAY_APP_ORG".equals(payMethodStr)) {
                // 微信APP支付_集团
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("vspCusid", vspCusid); // 收银宝子商户号
                payMap.put("limitPay", limitPay);// 非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("subAppId", subAppId);
                payMap.put("subMchId", subMchId);
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("WECHATPAY_APP_ORG", payMap);
            } else if ("ALIPAY_APP_OPEN".equals(payMethodStr)) {
                // 支付宝原生APP支付
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                // payMap.put("enablePayChannels", subAppId);
                // payMap.put("paysummary", subMchId);
                // payMap.put("acct", ali_user_id);
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("ALIPAY_APP_OPEN", payMap);
            } else if ("VIRTUAL_IN".equals(payMethodStr)) {
                // 通用虚拟入金
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                // payMap.put("vspCusid", vspCusid); //收银宝子商户号
                // payMap.put("limitPay", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMap.put("amount", amount); // 分
                payMap.put("extChannelNo", "AUTO");
                payMap.put("extAccount", "AUTO");
                payMap.put("paysummary", "AUTO");
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("VIRTUAL_IN", payMap);
            } else if ("WITHHOLD_SD".equals(payMethodStr)) {
                // 山东代收
                HashMap<String, Object> payMap = new HashMap<>();
                // aliPay.put("acct", ali_user_id);
                payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
                payMap.put("PROVINCE", "上海");
                payMap.put("CITY", "浦东新区");
                payMap.put("amount", amount); // 分
                // payMap.put("extChannelNo", "AUTO");
                // payMap.put("extAccount", "AUTO");
                payMap.put("paysummary", "AUTO");
                // payMap.put("payType", limitPay);//非贷记卡：no_credit; 借、贷记卡：””
                payMethod.put("WITHHOLD_SD", payMap);
            }

            // 组装支付方式

            // payMethod.put("QUICKPAY", quickPay);

            // payMethod.put("GATEWAY", gatewayPay);
            // payMethod.put("WITHHOLD_UP", daikouPay);
            // payMethod.put("WITHHOLD_TLT", tltDaikouPay);

            request.put("payerId", payerId);
            request.put("recieverList", recieverList);
            request.put("bizOrderNo", bizOrderNo);
            request.put("recieverId", recieverId);
            request.put("bizOrderNo", bizOrderNo);
            request.put("tradeCode", "3001"); //消费代收
            request.put("amount", amount);
            request.put("accountSetNo", accountSetNo);

            request.put("fee", 0L);
            request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码
            request.put("frontUrl", frontUrl);//前台通知地址
            request.put("backUrl", backUrl);// 后台通知地址

            request.put("ordErexpireDatetime", ordErexpireDatetime);
            request.put("payMethod", JSONObject.toJSON(payMethod));

            request.put("goodsName", "computer");
            request.put("industryCode", "1910");
            request.put("industryName", "其他");
            request.put("source", 2L);
            request.put("summary", "AUTO-TEST agentCollectApplySimplify");
            request.put("extendInfo", " this is extendInfo");


            String res = YunClient.request(request);
            System.out.println("res: " + res);
            JSONObject resp = JSON.parseObject(res);
            // System.out.println("status=[" + resp.getString("status") + "]");
            // System.out.println("signedValue=[" + resp.getString("signedValue") + "]");
            // System.out.println("sign=[" + resp.getString("sign") + "]");
            // System.out.println("errorCode=[" + resp.getString("errorCode") + "]");
            // System.out.println("message=[" + resp.getString("message") + "]");
            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                payStatus = resp.getJSONObject("signedValue").getString("payStatus");
                payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");
                orderNo = resp.getJSONObject("signedValue").getString("orderNo");
                tradeNo = resp.getJSONObject("signedValue").getString("tradeNo");
                payCode = resp.getJSONObject("signedValue").getString("payCode");
                extendInfo = resp.getJSONObject("signedValue").getString("extendInfo");
                payInfo = resp.getJSONObject("signedValue").getString("payInfo");
                if (payMethodStr.equals("WECHATPAY_APP")) {
                    appid = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("appid");
                    packageStr = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("package");
                    prepayid = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("prepayid");
                    partnerid = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("partnerid");
                    noncestr = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("noncestr");
                    timestamp = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("timestamp");
                    sign = resp.getJSONObject("signedValue").getJSONObject("weixinstr").getString("sign");
                }
                log.info("API[agentCollectApplySimplify SUCCESS!]");
            } else {
                log.error("API_ERROR[agentCollectApplySimplify RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("payerId", payerId);
        result.put("recieverId", recieverId);
        result.put("bizOrderNo", bizOrderNo);
        result.put("orderNo", orderNo);
        result.put("tradeNo", tradeNo);
        result.put("payCode", payCode);
        result.put("extendInfo", extendInfo);
        result.put("payInfo", payInfo);
        result.put("payStatus", payStatus);
        result.put("payFailMessage", payFailMessage);
        //wechat pay must info
        result.put("appid", appid);
        result.put("packageStr", packageStr);
        result.put("prepayid", prepayid);
        result.put("partnerid", partnerid);
        result.put("noncestr", noncestr);
        result.put("timestamp", timestamp);
        result.put("sign", sign);

        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: agentCollectApplySimplify end================[elapse: " + elapse + " ms]");
        return result;
    }
*/

    /**
     * 前台页面支付
     *
     * @param bizUserId
     * @param bizOrderNo
     * @param tradeNo
     * @param verificationCode
     * @param consumerIp
     * @return
     */
/*    public static HashMap<String, String> frontPay(String bizUserId, String bizOrderNo, String tradeNo,
                                                   String verificationCode, String consumerIp) {
        log.info("================OrderAPI: backPay begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "pay");

        HashMap<String, Object> payMethod = new HashMap<>();

        String payStatus = "";
        String payFailMessage = "";

        try {
            request.put("bizUserId", bizUserId);
            request.put("bizOrderNo", bizOrderNo);
            request.put("tradeNo", tradeNo); //快捷支付必传

            request.put("verificationCode", verificationCode); // 0: 无验证；1：短信；2：支付密码
            request.put("consumerIp", consumerIp);

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                payStatus = resp.getJSONObject("signedValue").getString("payStatus");
                payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");

                log.info("API[backPay SUCCESS!]");
            } else {
                log.error("API_ERROR[backPay RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizUserId", bizUserId);
        result.put("bizOrderNo", bizOrderNo);
        result.put("tradeNo", tradeNo);
        result.put("payStatus", payStatus);
        result.put("payFailMessage", payFailMessage);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: backPay end================[elapse: " + elapse + " ms]");
        return result;
    }*/

    /**
     * 后台确认支付-短信验证方式
     *
     * @param bizUserId
     * @param bizOrderNo
     * @param tradeNo
     * @param verificationCode
     * @param consumerIp
     * @return
     */
/*    public static HashMap<String, String> backPay(String bizUserId, String bizOrderNo, String tradeNo,
                                                  String verificationCode, String consumerIp) {
        log.info("================OrderAPI: backPay begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "pay");

        HashMap<String, Object> payMethod = new HashMap<>();

        String payStatus = "";
        String payFailMessage = "";

        try {
            request.put("bizUserId", bizUserId);
            request.put("bizOrderNo", bizOrderNo);
            request.put("tradeNo", tradeNo); //快捷支付必传

            request.put("verificationCode", verificationCode); // 0: 无验证；1：短信；2：支付密码
            request.put("consumerIp", consumerIp);

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                payStatus = resp.getJSONObject("signedValue").getString("payStatus");
                payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");

                log.info("API[backPay SUCCESS!]");
            } else {
                log.error("API_ERROR[backPay RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizUserId", bizUserId);
        result.put("bizOrderNo", bizOrderNo);
        result.put("tradeNo", tradeNo);
        result.put("payStatus", payStatus);
        result.put("payFailMessage", payFailMessage);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: backPay end================[elapse: " + elapse + " ms]");
        return result;
    }*/

    /**
     * 后台虚拟通道确认支付
     *
     * @param bizUserId
     * @param bizOrderNo
     * @param tradeNo
     * @param verificationCode
     * @param consumerIp
     * @return
     */
/*    public static HashMap<String, String> backVirtualPay(String bizUserId, String bizOrderNo, String tradeNo,
                                                         String verificationCode, String consumerIp) {
        log.info("================OrderAPI: backVirtualPay begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "payVirtual");

        HashMap<String, Object> payMethod = new HashMap<>();

        String payStatus = "";
        String payFailMessage = "";
        String extTradeNo = "AUTO-" + System.currentTimeMillis();
        try {
            request.put("bizUserId", bizUserId);
            request.put("bizOrderNo", bizOrderNo);

            request.put("flag", "confirm");
            request.put("extPayMethod", "AUTO");

            request.put("extTradeNo", extTradeNo); //快捷支付必传

            request.put("summary", "AUTO-TEST");
            request.put("consumerIp", consumerIp);

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                payStatus = resp.getJSONObject("signedValue").getString("payStatus");
                payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");

                log.info("API[backVirtualPay SUCCESS!]");
            } else {
                log.error("API_ERROR[backVirtualPay RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizUserId", bizUserId);
        result.put("bizOrderNo", bizOrderNo);
        result.put("extTradeNo", extTradeNo);
        result.put("payStatus", payStatus);
        result.put("payFailMessage", payFailMessage);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: backVirtualPay end================[elapse: " + elapse + " ms]");
        return result;
    }*/

    /**
     * 单笔托管代付到账户
     *
     * @param bizOrderNo     商户订单号（支付订单）
     * @param collectPayList 源托管代收订单付款信息
     * @param bizUserId      收款账户 bizUserId，支持个人 会员、企业会员
     * @param accountSetNo   收款人的账户集编号。云商通分配的托管专用账户集 的编号
     * @param backUrl        后台回调地址
     * @param amount         总金额
     * @param fee            手续费
     * @param tradeCode      业务码
     * @return 操作结果
     * @throws Exception 异常
     */
    public static String signalAgentPay(String bizOrderNo, JSONArray collectPayList, String bizUserId, String accountSetNo,
                                        String backUrl, Long amount, Long fee, String tradeCode, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "signalAgentPay");


        request.put("bizOrderNo", bizOrderNo);
        request.put("collectPayList", collectPayList);
        request.put("bizUserId", bizUserId); //收款方
        request.put("accountSetNo", accountSetNo);
        request.put("backUrl", backUrl);
        request.put("tradeCode", tradeCode);
        request.put("amount", amount);
        request.put("fee", fee);

        return YunClient.request(request, cacheParams, url);
    }

    /**
     * 批量托管代付到账户
     *
     * @param bizBatchNo   商户批次号
     * @param batchPayList 批量代付列表
     * @param tradeCode    业务码
     * @param backUrl      统一回调地址
     * @return 操作结果
     */
    public static String batchAgentPay(String bizBatchNo, List<BatchPayVO> batchPayList, String tradeCode, String backUrl,String cacheParams,String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "signalAgentPay");
        JSONArray batchPayListJSON = new JSONArray();
        if (!CollectionUtils.isEmpty(batchPayList)) {
            for (BatchPayVO batchPayVO : batchPayList) {
                JSONObject object = new JSONObject();
                JSONArray collectPayListJSON = new JSONArray();
                object.put("bizOrderNo", batchPayVO.getBizOrderNO());
                object.put("bizUserId", batchPayVO.getBizUserId());
                object.put("accountSetNo", batchPayVO.getAccountSetNo());
                object.put("backUrl", backUrl);
                object.put("amount", batchPayVO.getAmount());
                object.put("fee", batchPayVO.getFee());
                object.put("extendInfo", batchPayVO.getExtendInfo());
                if (!CollectionUtils.isEmpty(batchPayVO.getCollectPayList())) {
                    for (RecieverVO recieverVO : batchPayVO.getCollectPayList()) {
                        JSONObject reciever = new JSONObject();
                        reciever.put("bizOrderNo", recieverVO.getMemberId() + "__" + recieverVO.getMemberRoleId());
                        reciever.put("bizOrderCreateDate", recieverVO.getBizOrderCreateDate());
                        reciever.put("amount", new BigDecimal(String.valueOf(recieverVO.getAmount())).multiply(new BigDecimal("100")).longValue());
                        collectPayListJSON.add(reciever);
                    }
                }
                object.put("collectPayList", collectPayListJSON);
                batchPayListJSON.add(object);
            }
        }

        request.put("bizBatchNo", bizBatchNo);
        request.put("tradeCode", tradeCode);

        String res = YunClient.request(request,cacheParams,url);
        System.out.println("操作结果res:" + res);
        return res;
    }

    /**
     * 代笔代付到银行卡
     *
     * @param bizUserId
     * @param bizOrderNo
     * @param accountSetNo
     * @param backUrl
     * @param amount
     * @param bankCardNo
     * @return
     */
/*
    public static HashMap<String, String> signalAgentPaySimplify2BankCard(String bizUserId, String bizOrderNo, String accountSetNo,
                                                                          String backUrl, Long amount, String bankCardNo) {
        log.info("================OrderAPI: signalAgentPaySimplify2BankCard begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "signalAgentPaySimplify");

        HashMap<String, Object> payMethod = new HashMap<>();

        String payStatus = "";
        String payFailMessage = "";
        String orderNo = "";
        //String bizOrderNo = "";
        String payWhereabouts = "";
        String extTradeNo = "AUTO-" + System.currentTimeMillis();
        try {
            request.put("bizUserId", bizUserId); //商户系统用户标识，商户系统中唯一编号,收款账户bizUserId，支持个人会员、企业会员
            request.put("bizOrderNo", bizOrderNo);

            request.put("accountSetNo", accountSetNo);
            request.put("backUrl", backUrl);

            HashMap<String, Object> payToBankCardInfo = new HashMap<String, Object>();
            payToBankCardInfo.put("bankCardNo", bankCardNo);
            payToBankCardInfo.put("amount", amount);
            payToBankCardInfo.put("backUrl", backUrl);
            payToBankCardInfo.put("withdrawType", "T0");//T0：T+0到账;T1：T+1到账;T1customized：T+1到账，仅工作日代付;D0customized：D+0到账，根据平台资金头寸付款;默认为T0

            payToBankCardInfo.put("unionBank", "03080000"); // CMB
            payToBankCardInfo.put("province", "上海");
            payToBankCardInfo.put("city", "浦东新区");
            payToBankCardInfo.put("bankCardPro", 0L); //0：个人银行卡;1：企业对公账户;如果不传默认为0

            request.put("payToBankCardInfo", payToBankCardInfo);
            request.put("amount", amount);
            request.put("fee", 0L);
            //request.put("splitRuleList", "");
            request.put("goodsType", 3L);
            request.put("goodsNo", "AUTO-TEST-goodsNo");
            request.put("tradeCode", "4001");
            request.put("summary", "AUTO-TEST");
            request.put("extendInfo", "AUTO-TEST-extendInfo");

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                payStatus = resp.getJSONObject("signedValue").getString("payStatus");
                payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");
                orderNo = resp.getJSONObject("signedValue").getString("orderNo");
                bizOrderNo = resp.getJSONObject("signedValue").getString("bizOrderNo");
                payWhereabouts = resp.getJSONObject("signedValue").getString("payWhereabouts");
                log.info("API[signalAgentPaySimplify2BankCard SUCCESS! payStatus=" + payStatus + ",orderNo=" + orderNo + ", payWhereabouts=" + payWhereabouts + "]");
            } else {
                log.error("API_ERROR[signalAgentPaySimplify2BankCard RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizUserId", bizUserId);
        result.put("bizOrderNo", bizOrderNo);
        //result.put("extTradeNo", extTradeNo);
        result.put("payStatus", payStatus);
        result.put("payFailMessage", payFailMessage);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: signalAgentPaySimplify2BankCard end================[elapse: " + elapse + " ms]");
        return result;
    }
*/

    /**
     * 单笔代付-带分账；
     *
     * @param bizUserId
     * @param bizOrderNo
     * @param accountSetNo
     * @param backUrl
     * @param amount
     * @param bankCardNo
     * @return
     */
/*
    public static HashMap<String, String> signalAgentPaySimplifyWithSplitRules(String bizUserId, String bizOrderNo, String accountSetNo,
                                                                               String backUrl, Long amount, String bankCardNo) {
        log.info("================OrderAPI: signalAgentPaySimplifyWithSplitRules begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "signalAgentPaySimplify");

        HashMap<String, Object> payMethod = new HashMap<>();

        String payStatus = "";
        String payFailMessage = "";
        String orderNo = "";
        //String bizOrderNo = "";
        String payWhereabouts = "";
        String extTradeNo = "AUTO-" + System.currentTimeMillis();
        try {
            request.put("bizUserId", bizUserId); //商户系统用户标识，商户系统中唯一编号,收款账户bizUserId，支持个人会员、企业会员
            request.put("bizOrderNo", bizOrderNo);

            request.put("accountSetNo", accountSetNo);
            request.put("backUrl", backUrl);

            HashMap<String, Object> payToBankCardInfo = new HashMap<String, Object>();
            payToBankCardInfo.put("bankCardNo", bankCardNo);
            payToBankCardInfo.put("amount", amount);
            payToBankCardInfo.put("backUrl", backUrl);
            payToBankCardInfo.put("withdrawType", "T0");//T0：T+0到账;T1：T+1到账;T1customized：T+1到账，仅工作日代付;D0customized：D+0到账，根据平台资金头寸付款;默认为T0

            payToBankCardInfo.put("unionBank", "03080000"); // CMB
            payToBankCardInfo.put("province", "上海");
            payToBankCardInfo.put("city", "浦东新区");
            payToBankCardInfo.put("bankCardPro", 0L); //0：个人银行卡;1：企业对公账户;如果不传默认为0

            request.put("payToBankCardInfo", payToBankCardInfo);
            request.put("amount", amount);
            request.put("fee", 0L);

            //设置分账规则，固定：
            ArrayList splitRuleList = new ArrayList();
            HashMap<String, Object> splitRules1 = new HashMap<String, Object>();
            splitRules1.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules1.put("accountSetNo", accountSetNo);
            splitRules1.put("amount", 5L);
            splitRules1.put("fee", 0L);
            splitRules1.put("remark", "SplitRule AUTO-TEST");

            HashMap<String, Object> splitRules2 = new HashMap<String, Object>();
            splitRules2.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules2.put("accountSetNo", accountSetNo);
            splitRules2.put("amount", 2L);
            splitRules2.put("fee", 0L);
            splitRules2.put("remark", "SplitRule AUTO-TEST2");
            splitRules1.put("splitRuleList", splitRules2);
            //splitRuleList.add(splitRules2);
            splitRuleList.add(splitRules1);


            request.put("splitRuleList", splitRuleList);
            request.put("goodsType", 3L);
            request.put("goodsNo", "AUTO-TEST-goodsNo");
            request.put("tradeCode", "4001");
            request.put("summary", "AUTO-TEST");
            request.put("extendInfo", "AUTO-TEST-extendInfo");

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                payStatus = resp.getJSONObject("signedValue").getString("payStatus");
                payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");
                orderNo = resp.getJSONObject("signedValue").getString("orderNo");
                bizOrderNo = resp.getJSONObject("signedValue").getString("bizOrderNo");
                payWhereabouts = resp.getJSONObject("signedValue").getString("payWhereabouts");
                log.info("API[signalAgentPaySimplifyWithSplitRules SUCCESS! payStatus=" + payStatus + ",orderNo=" + orderNo + ", payWhereabouts=" + payWhereabouts + "]");
            } else {
                log.error("API_ERROR[signalAgentPaySimplifyWithSplitRules RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizUserId", bizUserId);
        result.put("bizOrderNo", bizOrderNo);
        //result.put("extTradeNo", extTradeNo);
        result.put("payStatus", payStatus);
        result.put("payFailMessage", payFailMessage);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: signalAgentPaySimplifyWithSplitRules end================[elapse: " + elapse + " ms]");
        return result;
    }
*/

    /**
     * 批量托管代付-简化
     *
     * @param bizUserId
     * @param accountSetNo
     * @param backUrl
     * @param amount
     * @param bankCardNo
     * @return
     */
/*
    public static HashMap<String, String> batchAgentPaySimplify(String bizUserId, String accountSetNo,
                                                                String backUrl, Long amount, String bankCardNo) {
        log.info("================OrderAPI: batchAgentPaySimplify begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "batchAgentPaySimplify");

        HashMap<String, Object> payMethod = new HashMap<>();

        //String payStatus = "";
        //String payFailMessage = "";
        //String orderNo = "";
        String bizOrderNo = "AUTO-" + System.currentTimeMillis();
        ;
        //String payWhereabouts = "";

        String bizBatchNo = "AUTO-" + System.currentTimeMillis();
        Long goodsType = 3L;  // real goods
        String goodsNo = "AUTO-goodsNo";
        String tradeCode = "3001";
        try {
            request.put("bizBatchNo", bizBatchNo); //商户批次号
            ArrayList list = new ArrayList();
            HashMap<String, Object> batchPayMap = new HashMap<String, Object>();
            batchPayMap.put("bizOrderNo", bizOrderNo);
            batchPayMap.put("bizUserId", bizUserId);
            batchPayMap.put("accountSetNo", accountSetNo);
            batchPayMap.put("backUrl", backUrl);
            batchPayMap.put("amount", amount);
            batchPayMap.put("fee", 0L);
            list.add(batchPayMap);
            request.put("batchPayList", list);
            request.put("summary", "AUTO-TEST--summary");
            request.put("extendInfo", "AUTO-TEST-extendInfo");

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                bizBatchNo = resp.getJSONObject("signedValue").getString("bizBatchNo");
//				payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");
//				orderNo = resp.getJSONObject("signedValue").getString("orderNo");
//				bizOrderNo = resp.getJSONObject("signedValue").getString("bizOrderNo");
//				payWhereabouts = resp.getJSONObject("signedValue").getString("payWhereabouts");
                log.info("API[batchAgentPaySimplify SUCCESS! bizBatchNo=" + bizBatchNo + "]");
            } else {
                log.error("API_ERROR[batchAgentPaySimplify RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizBatchNo", bizBatchNo);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: batchAgentPaySimplify end================[elapse: " + elapse + " ms]");
        return result;
    }
*/

    /**
     * 批量代付到银行卡
     *
     * @param bizUserId
     * @param accountSetNo
     * @param backUrl
     * @param amount
     * @param bankCardNo
     * @return
     */
/*    public static HashMap<String, String> batchAgentPaySimplify2BankCard(String bizUserId, String accountSetNo,
                                                                         String backUrl, Long amount, String bankCardNo) {
        log.info("================OrderAPI: batchAgentPaySimplify2BankCard begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "batchAgentPaySimplify");

        HashMap<String, Object> payMethod = new HashMap<>();

        //String payStatus = "";
        //String payFailMessage = "";
        //String orderNo = "";
        String bizOrderNo = "AUTO-" + System.currentTimeMillis();
        //String payWhereabouts = "";

        String bizBatchNo = "AUTO-" + System.currentTimeMillis();
        Long goodsType = 3L;  // real goods
        String goodsNo = "AUTO-goodsNo";
        String tradeCode = "3001";
        try {
            request.put("bizBatchNo", bizBatchNo); //商户批次号
            ArrayList list = new ArrayList();
            HashMap<String, Object> batchPayMap = new HashMap<String, Object>();
            batchPayMap.put("bizOrderNo", bizOrderNo);
            batchPayMap.put("bizUserId", bizUserId);
            batchPayMap.put("accountSetNo", accountSetNo);
            batchPayMap.put("backUrl", backUrl);

            HashMap<String, Object> payToBankCardInfo = new HashMap<String, Object>();
            payToBankCardInfo.put("bankCardNo", bankCardNo);
            payToBankCardInfo.put("amount", amount);
            payToBankCardInfo.put("backUrl", backUrl);
            payToBankCardInfo.put("withdrawType", "T0");//T0：T+0到账;T1：T+1到账;T1customized：T+1到账，仅工作日代付;D0customized：D+0到账，根据平台资金头寸付款;默认为T0

            payToBankCardInfo.put("unionBank", "03080000"); // CMB
            payToBankCardInfo.put("province", "上海");
            payToBankCardInfo.put("city", "浦东新区");
            payToBankCardInfo.put("bankCardPro", 0L); //0：个人银行卡;1：企业对公账户;如果不传默认为0

            //request.put("payToBankCardInfo", payToBankCardInfo);

            batchPayMap.put("payToBankCardInfo", payToBankCardInfo);
            batchPayMap.put("amount", amount);
            batchPayMap.put("fee", 0L);
            list.add(batchPayMap);

            bizOrderNo = "AUTO-" + System.currentTimeMillis();
            ;
            HashMap<String, Object> batchPayMap2 = new HashMap<String, Object>();
            batchPayMap2.put("bizOrderNo", bizOrderNo);
            batchPayMap2.put("bizUserId", bizUserId);
            batchPayMap2.put("accountSetNo", accountSetNo);
            batchPayMap2.put("backUrl", backUrl);
            batchPayMap2.put("amount", amount);
            batchPayMap2.put("fee", 0L);
            list.add(batchPayMap2);

            request.put("batchPayList", list);
            request.put("summary", "AUTO-TEST--summary");
            request.put("extendInfo", "AUTO-TEST-extendInfo");

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                bizBatchNo = resp.getJSONObject("signedValue").getString("bizBatchNo");
//				payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");
//				orderNo = resp.getJSONObject("signedValue").getString("orderNo");
//				bizOrderNo = resp.getJSONObject("signedValue").getString("bizOrderNo");
//				payWhereabouts = resp.getJSONObject("signedValue").getString("payWhereabouts");
                log.info("API[batchAgentPaySimplify2BankCard SUCCESS! bizBatchNo=" + bizBatchNo + "]");
            } else {
                log.error("API_ERROR[batchAgentPaySimplify2BankCard RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizBatchNo", bizBatchNo);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: batchAgentPaySimplify2BankCard end================[elapse: " + elapse + " ms]");
        return result;
    }

    *//**
     * 批量代付-带分账
     *
     * @param bizUserId
     * @param accountSetNo
     * @param backUrl
     * @param amount
     * @param bankCardNo
     * @return
     */
/*
    public static HashMap<String, String> batchAgentPaySimplifyWithSplitRule(String bizUserId, String accountSetNo,
                                                                             String backUrl, Long amount, String bankCardNo) {
        log.info("================OrderAPI: batchAgentPaySimplifyWithSplitRule begin================");
        long start = System.currentTimeMillis();
        HashMap<String, String> result = new HashMap<String, String>();
        final YunRequest request = new YunRequest("OrderService", "batchAgentPaySimplify");

        HashMap<String, Object> payMethod = new HashMap<>();

        //String payStatus = "";
        //String payFailMessage = "";
        //String orderNo = "";
        String bizOrderNo = "AUTO-" + System.currentTimeMillis();
        //String payWhereabouts = "";

        String bizBatchNo = "AUTO-" + System.currentTimeMillis();
        Long goodsType = 3L;  // real goods
        String goodsNo = "AUTO-goodsNo";
        String tradeCode = "3001";
        try {
            request.put("bizBatchNo", bizBatchNo); //商户批次号
            ArrayList list = new ArrayList();
            HashMap<String, Object> batchPayMap = new HashMap<String, Object>();
            batchPayMap.put("bizOrderNo", bizOrderNo);
            batchPayMap.put("bizUserId", bizUserId);
            batchPayMap.put("accountSetNo", accountSetNo);
            batchPayMap.put("backUrl", backUrl);

            HashMap<String, Object> payToBankCardInfo = new HashMap<String, Object>();
            payToBankCardInfo.put("bankCardNo", bankCardNo);
            payToBankCardInfo.put("amount", amount);
            payToBankCardInfo.put("backUrl", backUrl);
            payToBankCardInfo.put("withdrawType", "T0");//T0：T+0到账;T1：T+1到账;T1customized：T+1到账，仅工作日代付;D0customized：D+0到账，根据平台资金头寸付款;默认为T0

            payToBankCardInfo.put("unionBank", "03080000"); // CMB
            payToBankCardInfo.put("province", "上海");
            payToBankCardInfo.put("city", "浦东新区");
            payToBankCardInfo.put("bankCardPro", 0L); //0：个人银行卡;1：企业对公账户;如果不传默认为0

            //request.put("payToBankCardInfo", payToBankCardInfo);
            batchPayMap.put("payToBankCardInfo", payToBankCardInfo);
            batchPayMap.put("amount", amount);
            batchPayMap.put("fee", 0L);
            //设置分账规则，固定：
            ArrayList splitRuleList = new ArrayList();
            HashMap<String, Object> splitRules1 = new HashMap<String, Object>();
            splitRules1.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules1.put("accountSetNo", accountSetNo);
            splitRules1.put("amount", 5L);
            splitRules1.put("fee", 0L);
            splitRules1.put("remark", "SplitRule AUTO-TEST");
            splitRuleList.add(splitRules1);

            HashMap<String, Object> splitRules2 = new HashMap<String, Object>();
            splitRules2.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules2.put("accountSetNo", accountSetNo);
            splitRules2.put("amount", 2L);
            splitRules2.put("fee", 0L);
            splitRules2.put("remark", "SplitRule AUTO-TEST2");
            splitRuleList.add(splitRules2);
            batchPayMap.put("splitRuleList", splitRuleList);

            list.add(batchPayMap);

            bizOrderNo = "AUTO-" + System.currentTimeMillis();
            ;
            HashMap<String, Object> batchPayMap2 = new HashMap<String, Object>();
            batchPayMap2.put("bizOrderNo", bizOrderNo);
            batchPayMap2.put("bizUserId", bizUserId);
            batchPayMap2.put("accountSetNo", accountSetNo);
            batchPayMap2.put("backUrl", backUrl);
            batchPayMap2.put("amount", amount);
            batchPayMap2.put("fee", 0L);
            //设置分账规则，固定：
            ArrayList splitRuleList2 = new ArrayList();
            HashMap<String, Object> splitRules3 = new HashMap<String, Object>();
            splitRules3.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules3.put("accountSetNo", accountSetNo);
            splitRules3.put("amount", 5L);
            splitRules3.put("fee", 0L);
            splitRules3.put("remark", "SplitRule AUTO-TEST");
            splitRuleList2.add(splitRules3);

            HashMap<String, Object> splitRules4 = new HashMap<String, Object>();
            splitRules4.put("bizUserId", bizUserId);//TODO: 可以固定设置一个用户
            splitRules4.put("accountSetNo", accountSetNo);
            splitRules4.put("amount", 2L);
            splitRules4.put("fee", 0L);
            splitRules4.put("remark", "SplitRule AUTO-TEST2");
            splitRuleList2.add(splitRules4);
            batchPayMap2.put("splitRuleList", splitRuleList2);
            list.add(batchPayMap2);

            request.put("batchPayList", list);
            request.put("summary", "AUTO-TEST--summary");
            request.put("extendInfo", "AUTO-TEST-extendInfo");

            String res = YunClient.request(request);
            JSONObject resp = JSON.parseObject(res);

            String status = resp.getString("status");

            if (status != null && status.equals("OK")) {
                bizBatchNo = resp.getJSONObject("signedValue").getString("bizBatchNo");
//				payFailMessage = resp.getJSONObject("signedValue").getString("payFailMessage");
//				orderNo = resp.getJSONObject("signedValue").getString("orderNo");
//				bizOrderNo = resp.getJSONObject("signedValue").getString("bizOrderNo");
//				payWhereabouts = resp.getJSONObject("signedValue").getString("payWhereabouts");
                log.info("API[batchAgentPaySimplifyWithSplitRule SUCCESS! bizBatchNo=" + bizBatchNo + "]");
            } else {
                log.error("API_ERROR[batchAgentPaySimplifyWithSplitRule RESULT=[" + resp.getString("errorCode") + ", "
                        + resp.getString("message") + "]]");
            }
        } catch (final Exception e) {
            log.error("EXCEPTION", e);
            // e.printStackTrace();
        }
        result.put("bizBatchNo", bizBatchNo);
        long end = System.currentTimeMillis();
        long elapse = end - start;
        log.info("================OrderAPI: batchAgentPaySimplifyWithSplitRule end================[elapse: " + elapse + " ms]");
        return result;
    }
*/

    /**
     * 查询余额
     *
     * @param bizUserId    商户id
     * @param accountSetNo 账户集
     * @return 操作结果
     */
    public static String queryBalance(String bizUserId, String accountSetNo, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "queryBalance");
        if ("auto".equalsIgnoreCase(bizUserId)) {
            bizUserId = IDGenerator.generateGUID();
        }
        request.put("bizUserId", bizUserId);
        request.put("accountSetNo", accountSetNo);
        log.info("[bizUserId=" + bizUserId + ", memberType=3" + ", source=2]");
        return YunClient.request(request, cacheParams, url);

    }

    /**
     * 查询账户收支明细
     *
     * @param bizUserId     商户id
     * @param accountSetNo  账户集
     * @param dateStart     开始时间
     * @param dateEnd       结束时间
     * @param startPosition 开始位置
     * @param queryNum      查询条数
     * @param tradeType     交易类型
     * @return 查询结果
     * @throws Exception
     */
    public static String queryInExpDetail(String bizUserId, String accountSetNo, String dateStart, String dateEnd, Long startPosition, Long queryNum, Long tradeType, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "queryInExpDetail");
        if ("auto".equalsIgnoreCase(bizUserId)) {
            bizUserId = IDGenerator.generateGUID();
        }
        request.put("bizUserId", bizUserId);
        request.put("accountSetNo", accountSetNo);
        request.put("dateStart", dateStart);
        request.put("dateEnd", dateEnd);
        request.put("startPosition", startPosition);
        request.put("queryNum", queryNum);
        request.put("tradeType", tradeType);
        return YunClient.request(request, cacheParams, url);

    }

    /**
     * 通联支付-冻结金额
     *
     * @param bizUserId    商户id
     * @param bizFreeZenNo 商户冻结金额订单号
     * @param accountSetNo 账户集编号
     * @param amount       冻结金额
     * @return 冻结结果
     */
    public static String freezeMoney(String bizUserId, String bizFreeZenNo, String accountSetNo, Long amount, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "freezeMoney");
        if ("auto".equalsIgnoreCase(bizUserId)) {
            bizUserId = IDGenerator.generateGUID();
        }
        request.put("bizUserId", bizUserId);
        request.put("bizFreezenNo", bizFreeZenNo);
        request.put("accountSetNo", accountSetNo);
        request.put("amount", amount);
        return YunClient.request(request, cacheParams, url);

    }

    /**
     * 通联支付-解冻金额
     *
     * @param bizUserId    商户id
     * @param bizFreeZenNo 商户解冻金额订单号
     * @param accountSetNo 账户集编号
     * @param amount       解冻金额
     * @return 解冻结果
     */
    public static String unfreezeMoney(String bizUserId, String bizFreeZenNo, String accountSetNo, Long amount, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "unfreezeMoney");
        if ("auto".equalsIgnoreCase(bizUserId)) {
            bizUserId = IDGenerator.generateGUID();
        }
        request.put("bizUserId", bizUserId);
        request.put("bizFreezenNo", bizFreeZenNo);
        request.put("accountSetNo", accountSetNo);
        request.put("amount", amount);
        return YunClient.request(request, cacheParams, url);

    }

    /**
     * 联支付-设置支付密码【密码验证版】
     *
     * @param bizUserId    商户id
     * @param jumpPageType 跳转页面类型
     * @param phone        手机号码
     * @param identityType 证件类型
     * @param identityNo   证件号码
     * @param backUrl      后台通知地址
     * @param type         ;类型
     * @return 操作结果
     */
    public static String setPayPwd(String bizUserId, Integer jumpPageType, String phone, String name, Integer identityType, String identityNo, String backUrl, Integer type, String cacheParams, String url) throws Exception {
        YunRequest request = null;
        String gateWay = null;
        if (type == 1) {
            request = new YunRequest("MemberPwdService", "setPayPwd");
            if ("auto".equalsIgnoreCase(bizUserId)) {
                bizUserId = IDGenerator.generateGUID();
            }
            request.put("bizUserId", bizUserId);
            request.put("jumpPageType", jumpPageType);
            request.put("phone", phone);
            request.put("name", name);
            request.put("identityType", identityType);
            request.put("identityNo", RSAUtil.encrypt(identityNo, cacheParams));
            request.put("backUrl", backUrl);
            gateWay = "http://116.228.64.55:6900/yungateway/pwd/setPayPwd.html";
        }
        if (type == 2) {
            request = new YunRequest("MemberPwdService", "updatePayPwd");
            if ("auto".equalsIgnoreCase(bizUserId)) {
                bizUserId = IDGenerator.generateGUID();
            }
            request.put("bizUserId", bizUserId);
            request.put("jumpPageType", jumpPageType);
            request.put("phone", phone);
            request.put("name", name);
            request.put("identityType", identityType);
            request.put("identityNo", RSAUtil.encrypt(identityNo, cacheParams));
            request.put("backUrl", backUrl);
            gateWay = "http://116.228.64.55:6900/yungateway/pwd/updatePayPwd.html";
        }
        if (type == 3) {
            request = new YunRequest("MemberPwdService", "resetPayPwd");
            if ("auto".equalsIgnoreCase(bizUserId)) {
                bizUserId = IDGenerator.generateGUID();
            }
            request.put("bizUserId", bizUserId);
            request.put("jumpPageType", jumpPageType);
            request.put("phone", phone);
            request.put("name", name);
            request.put("identityType", identityType);
            request.put("identityNo", RSAUtil.encrypt(identityNo, cacheParams));
            request.put("backUrl", backUrl);
            gateWay = "http://116.228.64.55:6900/yungateway/pwd/resetPayPwd.html";
        }


        String param = YunClient.encodeOnce(request, cacheParams);
        return gateWay + "?" + param;

    }

    /**
     * 确认支付(后台+短信验证码确认)
     *
     * @param bizUserId        当前登录用户
     * @param bizOrderNo       订单申请的商户订单号 （支付订单）
     * @param tradeNo          交易编号
     * @param verificationCode 短信验证码
     * @param consumerIp       ip 地址
     * @return 操作结果
     */
    public static String pay(String bizUserId, String bizOrderNo, String tradeNo, String verificationCode, String consumerIp, String cacheParams, String url) throws Exception {

        final YunRequest request = new YunRequest("OrderService", "pay");
        request.put("bizUserId", bizUserId);
        request.put("bizOrderNo", bizOrderNo);
        // request.put("tradeNo", tradeNo);
        request.put("verificationCode", verificationCode);
        request.put("consumerIp", consumerIp);
        return YunClient.request(request, cacheParams, url);
    }

    /**
     * 确认支付(后台+短信验证码确认)
     *
     * @param bizUserId        当前登录用户
     * @param bizOrderNo       订单申请的商户订单号 （支付订单）
     * @param verificationCode 短信验证码
     * @param consumerIp       ip 地址
     * @return 操作结果
     */
    public static String gateWayPay(String bizUserId, String bizOrderNo, String verificationCode, String consumerIp, String cacheParams, String gateWay) throws Exception {

        final YunRequest request = new YunRequest("OrderService", "pay");
        request.put("bizUserId", bizUserId);
        request.put("bizOrderNo", bizOrderNo);
        request.put("consumerIp", consumerIp);
        // String gateWay="https://fintech.allinpay.com/yungateway/frontTrans.do"; 正式

        return gateWay + "?" + YunClient.encodeOnce(request, cacheParams);
    }

    /**
     * 消费申请 (余额支付方式)
     *
     * @param payerId      付款人
     * @param recieverId   收款人
     * @param bizOrderNo   商户订单号（支付订单）
     * @param amount       订单金额
     * @param fee          手续费
     * @param validateType 验证类型
     * @param frontUrl     前台返回地址
     * @param backUrl      后台回调地址
     * @param payMethodStr 支付方式
     * @param accountSetNo 账户集
     * @param industryCode 行业代码
     * @param industryName 行业名称
     * @param extendInfo   拓展信息
     * @return 操作结果
     * @throws Exception 异常
     */
    public static String balanceConsumeApply(String payerId, String recieverId, String bizOrderNo, Long amount, Long fee,
                                             Integer validateType, String frontUrl, String backUrl, String payMethodStr,
                                             String accountSetNo, String industryCode, String industryName, String extendInfo, String cacheParams, String url) throws Exception {

        final YunRequest request = new YunRequest("OrderService", "consumeApply");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();
        // 支付方式
        // 网关
        if ("BALANCE".equals(payMethodStr)) {
            // 账户余额（需对接）
            // payMap.put("payType", limitPay); //非贷记卡：no_credit; 借、贷记卡：””
            JSONArray balancePay = new JSONArray();
            JSONObject balance = new JSONObject();
            balance.put("accountSetNo", accountSetNo);
            balance.put("amount", amount);
            balancePay.add(balance);
            payMethod.put("BALANCE", balancePay);
            validateType = 1;//需要短信验证
        }
        // 组装支付方式
        // payMethod.put("QUICKPAY", quickPay);
        // payMethod.put("GATEWAY", gatewayPay);
        // payMethod.put("WITHHOLD_UP", daikouPay);
        // payMethod.put("WITHHOLD_TLT", tltDaikouPay);
        request.put("payerId", payerId);
        request.put("recieverId", recieverId);
        request.put("bizOrderNo", bizOrderNo);
        request.put("amount", amount);
        //request.put("accountSetNo", accountSetNo);
        request.put("fee", fee);
        request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码
        //	request.put("frontUrl", frontUrl);//前台通知地址
        request.put("backUrl", backUrl);// 后台通知地址
        request.put("ordErexpireDatetime", ordErexpireDatetime);
        request.put("payMethod", payMethod);
        //request.put("bankCardNo", RSAUtil.encrypt(bankCardNo));
        //request.put("bankCardPro", bankCardPro);
        //request.put("withdrawType", withdrawType);
        request.put("industryCode", industryCode);
        request.put("industryName", industryName);
        request.put("source", 2L);
        request.put("extendInfo", extendInfo);
        return YunClient.request(request, cacheParams, url);
    }

    /**
     * 消费申请-微信支付宝app小程序
     *
     * @param payerId      付款人
     * @param recieverId   收款人
     * @param bizOrderNo   商户订单号
     * @param amount       支付金额
     * @param fee          手续费
     * @param validateType 验证类型
     * @param frontUrl     前台回调地址
     * @param backUrl      后台回调地址
     * @param payMethodStr 支付方式
     * @param limitPay     非贷记卡：no_credit 借、贷记卡：””需要传空字符串， 不能不传
     * @param subAppId     微信小程序支付 appid 参数 当商户有多个小程序或公众号时接 口指定上送
     * @param acct         微信小程序支付 openid——微信分 配
     * @param industryCode 行业代码
     * @param industryName 行业名称
     * @param extendInfo   拓展信息
     * @return 返回结果
     * @throws Exception 异常
     */
    public static String scanBalanceConsumeApply(String payerId, String recieverId, String bizOrderNo, long amount,
                                                 long fee, Integer validateType, String frontUrl, String backUrl, String payMethodStr,
                                                 String limitPay, String vspCusId, String subAppId, String acct, String allInPayType,
                                                 String bankCardNo, String industryCode, String industryName, String extendInfo, String cacheParams, String url, String cusIp) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "consumeApply");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();
        // 支付方式
        if ("SCAN_WEIXIN_ORG".equals(payMethodStr)) {
            // 微信扫码支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusId);
            payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_WEIXIN_ORG", payMap);
        } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
            // 支付宝支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusId);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_ALIPAY_ORG", payMap);
        } else if ("WECHATPAY_MINIPROGRAM_ORG".equals(payMethodStr)) {
            // 微信小程序支付（集团）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusId);
            payMap.put("subAppid", subAppId);
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("acct", acct);
            payMethod.put("WECHATPAY_MINIPROGRAM_ORG", payMap);
        } else if ("SCAN_WEIXIN".equals(payMethodStr)) {
            // 微信扫码支付正扫
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("limitPay", limitPay);//非贷记卡：no_credit 借、贷记卡：””，需要传空字符 串，不能不传
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_WEIXIN", payMap);
        } else if ("SCAN_ALIPAY".equals(payMethodStr)) {
            // 支付宝支付正扫
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("limitPay", limitPay);
            payMethod.put("SCAN_ALIPAY", payMap);
        } else if ("GATEWAY_VSP".equals(payMethodStr)) {
            // 收银宝网关支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("amount", amount); // 分
            payMap.put("paytype", allInPayType);
            payMethod.put("GATEWAY_VSP", payMap);
            request.put("frontUrl", frontUrl);//前台通知地址
        } else if ("QUICKPAY_VSP".equals(payMethodStr)) {
            // 收银宝快捷支付
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("amount", amount); // 分
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMethod.put("QUICKPAY_VSP", payMap);
            validateType = 1;//需要短信验证
        } else if ("WECHATPAY_H5_OPEN".equals(payMethodStr)) {
            //微信原生H5支付
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("subAppId", subAppId); // 微信端应用ID:appid
            payMap.put("cusip", cusIp); // 用户下单及调起支付的终端IP
            payMap.put("sceneInfo", "[]");
            payMethod.put("WECHATPAY_H5_OPEN", payMap);
        }

        request.put("payerId", payerId);
        request.put("recieverId", recieverId);
        request.put("bizOrderNo", bizOrderNo);
        request.put("amount", amount);
        request.put("fee", fee);
        request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码

        request.put("backUrl", backUrl);// 后台通知地址
        request.put("ordErexpireDatetime", ordErexpireDatetime);
        request.put("payMethod", payMethod);
        request.put("industryCode", industryCode);
        request.put("industryName", industryName);
        request.put("source", 2L);
        request.put("extendInfo", extendInfo);
        return YunClient.request(request, cacheParams, url);
    }

    /**
     * 托管代收接口(余额支付专用)
     *
     * @param bizOrderNo   商户订单号（支付订单）
     * @param payerId      商户系统用户标识，商户 系统中唯一编号。 付款人
     * @param amount       订单金额
     * @param validateType 交易验证方式
     * @param frontUrl     前台通知地址
     * @param backUrl      后台通知地址
     * @param payMethodStr 支付方式
     * @param accountSetNo 账户集
     */
    public static String balanceAgentCollectApply(String bizOrderNo, String payerId, Long amount, Long fee,
                                                  Long validateType, String frontUrl, String backUrl, String payMethodStr, String accountSetNo,
                                                  String tradeCode, String industryCode, String industryName, String extendInfo, Integer source,
                                                  JSONArray recieverList, String cacheParams, String url) throws Exception {

        final YunRequest request = new YunRequest("OrderService", "agentCollectApply");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();

        if ("BALANCE".equals(payMethodStr)) {
            // 账户余额（需对接）
            JSONArray balancePay = new JSONArray();
            JSONObject balance = new JSONObject();
            balance.put("accountSetNo", accountSetNo);
            balance.put("amount", amount);
            balancePay.add(balance);
            payMethod.put("BALANCE", balancePay);
        }
        // 组装支付方式
        request.put("payerId", payerId);
        request.put("recieverList", recieverList);
        request.put("bizOrderNo", bizOrderNo);
        request.put("tradeCode", tradeCode); //消费代收 3001
        request.put("amount", amount);
        request.put("fee", fee);
        request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码
        request.put("frontUrl", frontUrl);//前台通知地址
        request.put("backUrl", backUrl);// 后台通知地址
        request.put("ordErexpireDatetime", ordErexpireDatetime);
        request.put("payMethod", JSONObject.toJSON(payMethod));
        request.put("industryCode", industryCode);
        request.put("industryName", industryName);
        request.put("source", source);
        request.put("extendInfo", extendInfo);
        return YunClient.request(request, cacheParams, url);
    }

    /**
     * 托管代收接口(微信支付宝app小程序)
     *
     * @param bizOrderNo   商户订单号（支付订单）
     * @param payerId      商户系统用户标识，商户 系统中唯一编号。 付款人
     * @param amount       订单金额
     * @param validateType 交易验证方式
     * @param frontUrl     前台通知地址
     * @param backUrl      后台通知地址
     * @param payMethodStr 支付方式
     * @return
     */
    public static String scanAgentCollectApply(String bizOrderNo, String payerId, Long amount, Long fee,
                                               Long validateType, String frontUrl, String backUrl, String payMethodStr, String limitPay, String vspCusId,
                                               String subAppId, String acct, String tradeCode, String allInPayType, String bankCardNo, String industryCode,
                                               String industryName, String extendInfo, Integer source, JSONArray recieverList, String cacheParams, String url, String cusIp) throws Exception {

        final YunRequest request = new YunRequest("OrderService", "agentCollectApply");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR, 15);
        Date date = calendar.getTime();
        String ordErexpireDatetime = sdf.format(date);
        HashMap<String, Object> payMethod = new HashMap<>();

        // 支付方式
        if ("SCAN_WEIXIN_ORG".equals(payMethodStr)) {
            // 微信扫码支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusId);
            payMap.put("payType", limitPay); // 非贷记卡：no_credit; 借、贷记卡：””
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_WEIXIN_ORG", payMap);
        } else if ("SCAN_ALIPAY_ORG".equals(payMethodStr)) {
            // 支付宝支付正扫 集团
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusId);
            // aliPay.put("payType", "A01"); //传值：A01
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_ALIPAY_ORG", payMap);
        } else if ("WECHATPAY_MINIPROGRAM_ORG".equals(payMethodStr)) {
            // 微信小程序支付（集团）
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("vspCusid", vspCusId);
            payMap.put("subAppid", subAppId);
            payMap.put("limitPay", limitPay);
            payMap.put("amount", amount); // 分
            payMap.put("acct", acct);
            payMethod.put("WECHATPAY_MINIPROGRAM_ORG", payMap);
        } else if ("SCAN_WEIXIN".equals(payMethodStr)) {
            // 微信扫码支付正扫
            HashMap<String, Object> payMap = new HashMap<>();
            payMap.put("limitPay", limitPay);//非贷记卡：no_credit 借、贷记卡：””，需要传空字符 串，不能不传
            payMap.put("amount", amount); // 分
            payMethod.put("SCAN_WEIXIN", payMap);
        } else if ("SCAN_ALIPAY".equals(payMethodStr)) {
            // 支付宝支付正扫
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("limitPay", limitPay);
            payMethod.put("SCAN_ALIPAY", payMap);
        } else if ("GATEWAY_VSP".equals(payMethodStr)) {
            // 收银宝网关支付
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("paytype", allInPayType);
            payMap.put("limitPay", limitPay);//非贷记卡：no_credit 借、贷记卡：””，需要传空字符 串，不能不传
            payMethod.put("GATEWAY_VSP", payMap);
            frontUrl = "test";
        } else if ("QUICKPAY_VSP".equals(payMethodStr)) {
            // 收银宝快捷支付
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("bankCardNo", RSAUtil.encrypt(bankCardNo, cacheParams));
            payMethod.put("QUICKPAY_VSP", payMap);
        } else if ("WECHATPAY_H5_OPEN".equals(payMethodStr)) {
            //微信原生H5支付
            HashMap<String, Object> payMap = new HashMap<>();
            // wechatMiniPay.put("vspCusid", vspCusid);
            payMap.put("amount", amount); // 分
            payMap.put("subAppId", subAppId); // 微信端应用ID:appid
            payMap.put("cusip", cusIp); // 用户下单及调起支付的终端IP
            payMap.put("sceneInfo", "[]");
            payMethod.put("WECHATPAY_H5_OPEN", payMap);
        }

        // 组装支付方式
        request.put("payerId", payerId);
        request.put("recieverList", recieverList);
        request.put("bizOrderNo", bizOrderNo);
        request.put("tradeCode", tradeCode); //消费代收 3001
        request.put("amount", amount);
        request.put("fee", fee);
        request.put("validateType", validateType); // 0: 无验证；1：短信；2：支付密码
        request.put("frontUrl", frontUrl);//前台通知地址
        request.put("backUrl", backUrl);// 后台通知地址
        request.put("ordErexpireDatetime", ordErexpireDatetime);
        request.put("payMethod", JSONObject.toJSON(payMethod));
        request.put("industryCode", industryCode);
        request.put("industryName", industryName);
        request.put("source", source);
        request.put("extendInfo", extendInfo);
        return YunClient.request(request, cacheParams, url);
    }

    /**
     * 退款接口
     *
     * @param bizOrderNo    商户订单号（支付订单）
     * @param oriBizOrderNo 商户原订单号
     * @param bizUserId     商户系统用户标识，商户 系统中唯一编号。 退款收款人。
     * @param refundType    退款方式
     * @param refundList    收款人的退款金额
     * @param backUrl       后台通知地址
     * @param amount        本次退款总金额
     * @param couponAmount  代金券退款金额
     * @param feeAmount     手续费退款金额
     * @param extendInfo    扩展信息
     * @return 操作结果
     */
    public static String refund(String bizOrderNo, String oriBizOrderNo, String bizUserId, String refundType,
                                List<RefundPayeeVO> refundList, String backUrl, Long amount, Integer couponAmount, Integer feeAmount, String extendInfo, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "refund");
        JSONArray refundListJSON = new JSONArray();
        if (!CollectionUtils.isEmpty(refundList)) {
            for (RefundPayeeVO refundPayeeVO : refundList) {
                JSONObject object = new JSONObject();
                object.put("bizUserId", refundPayeeVO.getBizUserId());
                //object.put("accountSetNo", refundPayeeVO.getAccountSetNo());
                object.put("amount", refundPayeeVO.getAmount());
                refundListJSON.add(object);
            }
        }
        request.put("bizOrderNo", bizOrderNo);
        request.put("oriBizOrderNo", oriBizOrderNo);
        request.put("bizUserId", bizUserId);
        request.put("refundType", refundType);
        request.put("refundList", refundListJSON);
        request.put("backUrl", backUrl);
        request.put("amount", amount);
        request.put("couponAmount", couponAmount);
        request.put("feeAmount", feeAmount);
        request.put("extendInfo", extendInfo);
        return YunClient.request(request, cacheParams, url);

    }

    /**
     * 平台转账
     *
     * @param bizTransferNo      商户系统转账订单号，商户系统唯一
     * @param sourceAccountSetNo 源账户集编号
     * @param targetBizUserId    目标商户系统用户标识,商户系统中唯一编号。
     * @param targetAccountSetNo 目标账户集编号
     * @param amount             金额
     * @param extendInfo         拓展信息
     * @return 操作结果
     */
    public static String applicationTransfer(String bizTransferNo, String sourceAccountSetNo, String targetBizUserId, String targetAccountSetNo, long amount, String extendInfo, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "applicationTransfer");
        request.put("bizTransferNo", bizTransferNo);
        request.put("sourceAccountSetNo", sourceAccountSetNo);
        request.put("targetBizUserId", targetBizUserId);
        request.put("targetAccountSetNo", targetAccountSetNo);
        request.put("amount", amount);
        request.put("extendInfo", extendInfo);
        return YunClient.request(request, cacheParams, url);

    }

    /**
     * 重发短信验证码
     *
     * @param bizOrderNo 商户订单号
     * @return 操作结果
     */
    public static String resendPaySMS(String bizOrderNo, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "resendPaySMS");
        request.put("bizOrderNo", bizOrderNo);
        return YunClient.request(request, cacheParams, url);
    }

    /**
     * 订单分账退款申请
     *
     * @param bizOrderNo      商户订单号
     * @param oriBizOrderNo   商户原订单号
     * @param bizUserId       退款收款人
     * @param refundType      退款方式
     * @param orderRefundList 订单退款列表
     * @param backUrl         后台通知地址
     * @param cacheParams     缓存参数
     * @param url             请求路径
     * @return 操作结果
     */
    public static String orderSplitRefund(String bizOrderNo, String oriBizOrderNo, String bizUserId, String refundType, JSONArray orderRefundList, String backUrl, String cacheParams, String url) throws Exception {
        final YunRequest request = new YunRequest("OrderService", "orderSplitRefund");
        request.put("bizOrderNo", bizOrderNo);
        request.put("oriBizOrderNo", oriBizOrderNo);
        request.put("bizUserId", bizUserId);
        request.put("refundType", refundType);
        request.put("orderRefundList", orderRefundList);
        request.put("backUrl", backUrl);
        return YunClient.request(request, cacheParams, url);
    }
}
